﻿using System.Collections.Generic;
using TellStick;
using TellStick.Models;

namespace haunstm_test_telldus
{
    public class RegisterableDevices
    {

        public static IEnumerable<TellStickDevice> Tellstics()
        {
            var devices = new List<TellStickDevice>() { PreparedTellStickDevice("Halldimmer",        new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.CodeSwitch, "H","5"),
                                                        PreparedTellStickDevice("Vardagsrumsdimmer", new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.CodeSwitch, "H","1"),
                                                        PreparedTellStickDevice("Enhet 1",           new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.SelfLearningSwitch, "207001","2"),
                                                        PreparedTellStickDevice("Enhet 2",           new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.SelfLearningSwitch, "207002","2"),
                                                        PreparedTellStickDevice("Enhet 3",           new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.SelfLearningSwitch, "207003","2"),
                                                        PreparedTellStickDevice("Enhet 4",           new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.SelfLearningSwitch, "207004","2"),
                                                        PreparedTellStickDevice("Enhet 5",           new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.SelfLearningSwitch, "207005","2"),
                                                        PreparedTellStickDevice("Enhet 6",           new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.SelfLearningSwitch, "207006","2"),
                                                        PreparedTellStickDevice("Enhet 7",           new TellStick.Models.ModelNexa(), TellStick.TellStickSettingTypes.SelfLearningSwitch, "207007","2")};

            return devices;
        }

        private static TellStickDevice PreparedTellStickDevice(string name, ModelBase modelBase, TellStickSettingTypes controlType, string house, string unit)
        {
            var device = new TellStick.TellStickDevice(name, modelBase, controlType);
            device.SetParameter(TellStickParameterTypes.House, house);
            device.SetParameter(TellStickParameterTypes.Unit, unit);

            return device;
        }

    }
}
